<template>
  <div class="home">
    <h1>Home</h1>
    <ul>
      <li
          v-for="item of $store.state.list"
          :key="item.id"
      >
        {{ item.text }}
      </li>
    </ul>
    <h3>filterList：</h3>
    <ul>
      <li
          v-for="item of $store.getters.filterList"
          :key="item.id"
      >
        {{ item.text }}
      </li>
    </ul>
    <div>
      <input type="text" v-model="itemText">
      <button @click="handleSubmit">提交</button>
    </div>
    <hr>
    <h1>{{ $store.state.msg }}</h1>
    <h2>state.counter: {{ $store.state.counter }}</h2>
    <button @click="$store.commit('UPDATE_COUNTER')">提交 mutation 修改 counter</button>
    |
    <button @click="$store.dispatch('setCounterAction')">触发 action 修改 counter</button>
    <h3>getters counter100: {{ $store.getters.counter100 }}</h3>
  </div>
</template>

<script>
export default {
  name: 'HomeView',
  data() {
    return {
      itemText: ''
    }
  },
  methods: {
    handleSubmit() {
      this.$store.commit('SET_LIST', this.itemText)
    }
  }
}
</script>
